﻿
namespace Aeon.Emulator.Instructions.BitwiseLogic
{
    internal static class Or
    {
        [Opcode("08/r rmb,rb|0A/r rb,rmb|0C al,ib|80/1 rmb,ib", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void ByteOr(Processor p, ref byte dest, byte src)
        {
            dest = (byte)(dest | src);
            p.Flags &= ~(EFlags.Overflow | EFlags.Carry);
            p.ByteUpdateFlags((sbyte)dest, dest, EFlags.Sign | EFlags.Zero | EFlags.Parity);
        }

        [Opcode("09/r rmw,rw|0B/r rw,rmw|0D ax,iw|81/1 rmw,iw|83/1 rmw,ibx", AddressSize = 16 | 32)]
        public static void WordOr(Processor p, ref ushort dest, ushort src)
        {
            dest = (ushort)(dest | src);
            p.Flags &= ~(EFlags.Overflow | EFlags.Carry);
            p.WordUpdateFlags((short)dest, dest, EFlags.Sign | EFlags.Zero | EFlags.Parity);
        }
        [Alternate("WordOr", AddressSize = 16 | 32)]
        public static void DWordOr(Processor p, ref uint dest, uint src)
        {
            dest = (uint)(dest | src);
            p.Flags &= ~(EFlags.Overflow | EFlags.Carry);
            p.DWordUpdateFlags((int)dest, dest, EFlags.Sign | EFlags.Zero | EFlags.Parity);
        }
    }
}
